import { Row } from "antd";
import { websiteSettingApi } from "apis";
import { Component } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import Gopher2d from "./component/Gopher2d";
import Header from "./component/Header";
import Lived2d from "./component/Lived2d";
import ArticlePage from "./page/Article/One";
import ArticleListPage from "./page/Article/List";
import "./App.css";

export default class App extends Component {
	// 构造函数
	constructor(props) {
		super(props);
		this.state = { title: "Daived's blog" };
	}

	// render 后调用
	componentDidMount() {
		// 网站配置请求
		const _this = this;
		websiteSettingApi().then(function (res) {
			_this.setState({ title: res.data.title });
		});
	}
	render() {
		return (
			<div id="app">
				<Row className="index-page">
					<Header title_={this.state.title}></Header>
					<div className="container">
						<Switch>
							<Route path="/article/list/:text" component={ArticleListPage} />
							<Route path="/article/list" component={ArticleListPage} />
							<Route path="/article/one/:id" component={ArticlePage} />
							<Redirect to="/article/list" />
						</Switch>
					</div>
					<Gopher2d isShow={true} />
					{/* isShow 是否加载组件 */}
					<Lived2d isShow={false} />
				</Row>
			</div>
		);
	}
}
